Skip to content

fix: Use the server's FDv1 fallback TTL from the header and goodbye - #278

Merged
beekld merged 4 commits into
mainfrom
devin/1795126798-server-fallback-ttl
Dec 1, 2026
Merged

beekld merged 4 commits into
mainfrom
devin/1795126798-server-fallback-ttl

Conversation

@beekld

@beekld beekld commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Closes SDK-2987. Follows #265 and #273, the goodbye TTL parsing in java-sdk-internal 1.13.1. Spec: DATASYSTEM 1.6 (sdk-specs#251).

Describe the solution you've provided

Previously the server SDK always used the jittered 1h default as the FDv1 fallback TTL. It now uses the TTL the server sends.

  • Reads X-LD-FD-Fallback-TTL from the response that carries X-LD-FD-Fallback, for both polling and streaming.
  • A goodbye that has protocolFallbackTTL is now itself a fallback directive, and its TTL takes precedence over the header's.
  • A server TTL in (0, 1h] is used as-is, with no jitter. A missing, malformed, zero, negative, or >1h TTL uses the jittered 1h default.
  • This applies to the initializer path, to the synchronizer path, and to a directive received during FDv1 fallback, which replaces the TTL.
  • FDv2SourceResult (experimental package) now carries a nullable FDv1Fallback directive, with a nullable getTtl(), in place of the boolean fdv1Fallback.
Implementation details
  • Bumps launchdarklyJavaSdkInternal from 1.13.0 to 1.13.1, which provides FDv2ActionGoodbye.getProtocolFallbackTTLMillis().
  • The header is parsed as whole seconds in HeaderConstants. A non-integer value gives a directive with a null TTL, which means the default.
  • The (0, 1h] check and the jitter live in one place, FDv2DataSource.fallbackTTL(Duration). InitializerOutcome now carries the directive.
  • Callers that passed false (file data source, TestDataV2, DataSourceSynchronizerAdapter) now pass null.
  • Tests: header parsing (valid and malformed), goodbye with and without a TTL in polling and streaming, directive preserved by the result copies, valid TTL used unjittered, invalid TTLs falling back to the default, and initializer and synchronizer fallback. ./gradlew test checkstyleMain checkstyleTest passes in lib/sdk/server.

Link to Devin session: https://app.devin.ai/sessions/cce64c67519f4babaa75176c06961c5e
Open in Devin Desktop: https://app.devin.ai/desktop/session/cce64c67519f4babaa75176c06961c5e?variant=devin
Requested by: @beekld


Note

Overview
Replaces the FDv1 fallback boolean on FDv2SourceResult with an FDv1Fallback directive (optional TTL) so the server can control how long FDv1 fallback runs before FDv2 is retried.

X-LD-FD-Fallback-TTL is parsed alongside X-LD-FD-Fallback for polling and streaming responses. goodbye events can carry protocolFallbackTTL, which wins over header TTL when present. Valid server TTLs in (0, 1h] are used without jitter; missing, invalid, zero, negative, or >1h values fall back to the existing jittered default via FDv2DataSource.fallbackTTL.

Initializer and synchronizer orchestration propagate the full directive (including TTL refresh while already on FDv1). Integrations that never signaled fallback now pass null instead of false. Tests cover header/goodbye parsing, TTL validation, and end-to-end recovery timing.

Reviewed by Cursor Bugbot for commit 5bae068. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

return interrupted(errorInfo, fdv1Fallback, null, completionCallback);
}

public static FDv2SourceResult interrupted(DataSourceStatusProvider.ErrorInfo errorInfo, boolean fdv1Fallback, Duration fdv1FallbackTTL, Function<Void, Void> completionCallback) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more future-proof design might be to replace boolean fdv1Fallback, Duration fdv1FallbackTT with a new nullable FDv1Fallback object that contains a Duration ttl. That way, if the format changes in the future, we don't have to change all the interfaces.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 71beeaa. There's a new datasources.FDv1Fallback, holding a nullable Duration ttl. The FDv2SourceResult factories now take a nullable FDv1Fallback in place of the boolean, where null means no directive, so the extra TTL overloads are gone. getFdv1Fallback() returns the directive, and isFdv1Fallback() remains as a != null shorthand.

devin-ai-integration Bot and others added 2 commits November 20, 2026 00:00
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 30, 2026 23:39
@devin-ai-integration
devin-ai-integration Bot requested a review from a team as a code owner November 30, 2026 23:39
@cursor cursor Bot added the risk:medium label Nov 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium.

Automated risk review (dry run): Medium

This PR would not be automatically approved. Human approval required.

Why: This changes FDv1 fallback TTL handling in the Java server SDK data source (FDv2DataSource, PollingBase, StreamingSynchronizerImpl, HeaderConstants, and experimental FDv2SourceResult/FDv1Fallback), a protocol-behavior change across polling, streaming, initializer, and synchronizer paths. Tests cover the new TTL rules, but the blast radius is more than a narrow low-risk edit.

Human review is needed and no reviewers were assigned.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Not approved: this exceeds the low-risk approval threshold (SDK rules 2–3 would otherwise allow it; rule 1 does not apply). Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@@ -0,0 +1,30 @@
package com.launchdarkly.sdk.server.datasources;

import java.time.Duration;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine in server, but we did recently make a PR to change one of these in internal or common. Because it isn't in the android API level that we use. But I wonder if we want to just not use java.time.Duration, or we just avoid it in the common libraries.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only in the server SDK, which already uses java.time.Duration in 33 main source files on main, including the existing defaultFDv1FallbackTTL. The goodbye TTL comes from the internal lib as nullable Long millis, as of #273, and is converted to a Duration only here. As far as I can tell, lib/shared/common and lib/shared/internal have no java.time.Duration left. So "avoid it in the common libraries" seems to be the rule today, and this PR follows it. I'll leave it as is unless you'd like the server SDK to avoid it too.

Written by Devin

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside: I've seen so many bugs from code that disagreed about whether a Long was seconds or millis, I'm inclined to use Duration where we can. But I know we don't want to require desugaring in Android, so... well, I'll deal either way.

Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
@beekld
beekld merged commit e279d61 into main Dec 1, 2026
32 checks passed
@beekld
beekld deleted the devin/1795126798-server-fallback-ttl branch December 1, 2026 21:25
kinyoklion added a commit that referenced this pull request Dec 3, 2026
…rce configuration (#222)

<!-- TERMAG_PR_BODY_BEGIN -->
## Update, 2026-12-01

- Rebased onto `feat/overrides`, which has `main` merged into it again.
From `main` it gets the 7.19.0 to 7.19.2 releases, `java-sdk-internal`
1.14.0, and the FDv2 fix that leaves out an empty selector (#261). The
v3.2.0-alpha.21 contract tests check that fix, so CI failed three FDv2
streaming tests without it.
- The `@since` tags this PR adds now say 7.20.0, because 7.19.0 to
7.19.2 shipped from `main` without flag overrides. The change is in the
existing commit "docs: Give the flag override API the version that will
ship it".
- `main` replaced the boolean FDv1 fallback argument of
`FDv2SourceResult.changeSet` with an `FDv1Fallback` (#278). The override
test data source passes `null`, as `main`'s own callers do. The change
is in the first commit.
- Verified with the v3.2.0-alpha.21 harness that CI runs, with `common`
2.6.0 and `internal` 1.15.0 published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
- the server unit tests pass at the top (2348, with the 72 existing
skips);
- the full v3 contract tests pass at the top (6457 tests ran). That
includes the flag overrides suite and both flag listener suites.

## Update, 2026-11-13

- Rebased onto `feat/overrides`, which now includes #218 and #219 and
has `main` merged into it. From `main` it gets the 7.18.0 release, CI on
the latest v3 contract tests, flag change listener support in the
contract test service, and the `java-sdk-internal` 1.12.1 and 1.12.2
fixes. A common 2.6.0 and internal 1.13.0 release from this branch needs
those fixes.
- New commit, "docs: Give the flag override API the version that will
ship it". Java 7.18.0 was released from `main` without flag overrides,
so the `@since` tags this PR adds now say 7.19.0, the next minor
release.
- Verified at the top of the stack, with `common` and `internal`
published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
  - the server unit tests pass (2285, with the 72 existing skips);
- the full v3 contract tests pass (6321 tests). That includes the flag
overrides suite, with the deleted-entry tests of
launchdarkly/sdk-test-harness#599, and both flag listener suites.

## Summary

This adds the override layer that the OVERRIDE specification describes:
an override source supplies complete snapshots of flag and segment
definitions to an override store, and an overlay at the store read
boundary returns the store's entry for a key in preference to
LaunchDarkly data. Evaluation, prerequisite and segment resolution, and
the all-flags state all read through the overlay, so an override is a
full definition that evaluates like any other. Overrides do not take
part in the data system: they have no effect on initialization status,
data availability, or data source status, and they are never written to
a persistent store.

Public surface, all marked experimental and subject to change:

- `DataSystemBuilder.overrides(ComponentConfigurer<OverrideSource>)` and
`DataSystemConfiguration.getOverrideSource()`. The option lives on the
FDv2 data system builder only. An FDv1 data source configuration has no
place to supply one.
- `subsystems.OverrideSource` (start with a sink, close) and
`subsystems.OverrideSink` (replace the whole layer with one snapshot).
The SDK builds the source like any other component, starts it before the
data source so its initial load completes during client construction,
and closes it with the client; the sink stops accepting snapshots before
the source is closed, and an exception from the source's `close` is
logged while the rest of the shutdown proceeds. An offline client does
not build or start the override source, and logs a warning that it does
not. A source that cannot be built fails client construction the same
way other invalid component configuration does. An exception from the
source's `start` does not: the SDK logs it, closes the source, clears
anything the source supplied before failing, and the client runs without
overrides.

Internals:

- `OverrideLayer` holds marked shallow copies of the supplied entities
in an immutable map that is swapped on each update. The source's objects
are never modified.
- `OverrideOverlayStore` implements the read boundary: per-key reads
prefer the layer, enumeration is the union with override precedence, and
a failure of the base store propagates, as it does without the overlay.
- `OverrideSinkImpl` serializes snapshot application and fires the
normal flag change notifications for every flag whose merged-view
evaluation may have changed, using the dependency tracker over both the
old and the new merged views so prerequisite and segment dependents are
included.
- The not-initialized short-circuit consults the layer first: a flag
that the layer holds is served before the client has LaunchDarkly data,
and any other flag returns the client-not-ready default as before.
Before the store is initialized, the all-flags state contains only the
flags that the layer holds, read from the layer rather than the merged
store so that LaunchDarkly data in a store without an init marker stays
out, and it logs once that it returned only override entries; with no
override flags the state is invalid, as it is without a source. Without
a source this state is empty, because the SDK reports no flags before
the store is initialized, so the override flags only add to what it
reports; overrides never remove a flag from the state. When the store
fails to list its flags, the failure is logged as before; the state,
invalid and empty without a source, then holds the override layer's
flags and stays invalid (empty and invalid when the layer holds no
flags), because a client-side SDK bootstrapped from it uses its flags
whatever `$valid` says. The all-flags state presents an
override-affected flag with `trackEvents` and `trackReason` false and no
`debugEventsUntilDate`.

The OVERRIDE specification's test vectors run as a unit test through the
full client stack (value, variation index, and reason). The
per-evaluation summary marker in the vectors is asserted by the events
change that follows.

This PR depends on the model and evaluator marking change
(rlamb/overrides-java-model-marker) and is based on that branch;
retarget it to feat/overrides once that branch merges.

The existing file data source keeps its current behavior; this change
does not touch its code paths.

[SDK-3246](https://launchdarkly.atlassian.net/browse/SDK-3246)


[SDK-3246]:
https://launchdarkly.atlassian.net/browse/SDK-3246?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

## Follow-ups from review

- A LaunchDarkly change now notifies the flags whose overrides depend on
it. The override layer keeps the dependency edges of its own entries,
rebuilt on every replacement, and `DataSourceUpdatesImpl` expands each
changed LaunchDarkly item through both its own tracker and the layer's
until nothing new is reached, so an override that matches a LaunchDarkly
segment or has a LaunchDarkly prerequisite is notified like the
LaunchDarkly flags that depend on it.
- `isFlagKnown` consults the override layer before the not-initialized
short circuit, the same as evaluation does, so an override-only flag is
known while the client is uninitialized.
- When the evaluation of a flag throws during `allFlagsState`, the
`EXCEPTION` result carries that flag's own override marking, so an
overridden flag keeps its marked reason with event tracking off.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds an **experimental flag/segment override** path for FDv2 clients
so operators can force known definitions without changing initialization
or data-source status.
> 
> Configuration wires in `DataSystemBuilder.overrides()` with public
`OverrideSource` / `OverrideSink` APIs. When configured,
`FDv2DataSystem` builds an `OverrideLayer`, applies snapshots via
`OverrideSinkImpl`, and exposes evaluations through
`OverrideOverlayStore` (overrides win per key). The override source
starts before the main data source; start/close failures are logged and
the client can run without overrides. Offline mode skips the override
source.
> 
> Evaluation and client behavior are updated so override-backed flags
work **before** the client is initialized (`isFlagKnown`, single-flag
eval, `allFlagsState` with override-only/bootstrap semantics).
Override-affected results carry marking in reasons and **disable**
per-flag analytics fields in `FeatureFlagsState`. Flag-change
notifications fan out across merged LaunchDarkly + override dependency
graphs via `ExternalDependencies` on `DataSourceUpdatesImpl`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
59f203e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=java-core -->
<sub>Opened from termag</sub>
kinyoklion pushed a commit that referenced this pull request Dec 3, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.20.0](launchdarkly-java-server-sdk-7.19.2...launchdarkly-java-server-sdk-7.20.0)
(2026-12-03)


### Features

* Add experimental support for file-based flag overrides
([5b3d8ea](5b3d8ea))


### Bug Fixes

* Keep flag file content out of the file data source's parse error
messages
([5b3d8ea](5b3d8ea))
* Prevent YAML flag files that are parsed at the same time from
returning each other's data
([5b3d8ea](5b3d8ea))
* Report a YAML flag file value that does not match its explicit tag as
invalid data instead of an unexpected exception
([5b3d8ea](5b3d8ea))
* Use the server's FDv1 fallback TTL from the header and goodbye
([#278](#278))
([e279d61](e279d61))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> This is a **Release Please** cut that publishes
**launchdarkly-java-server-sdk 7.20.0**. The diff only bumps version
metadata (`.release-please-manifest.json`, `gradle.properties`, and
`Version.SDK_VERSION`) and adds the **7.20.0** section to
`CHANGELOG.md`.
> 
> That release (already landed on `main`) includes **experimental
file-based flag overrides**, several **file/YAML `FileData` source**
fixes (no flag content in parse errors, concurrent YAML isolation,
clearer invalid-tag handling), and **FDv1 fallback TTL** behavior
aligned with server headers/goodbye ([#278]).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6284b29. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants